<template>
  <div class="app-container">
    <div>
      <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="120px">
        <el-form-item label="省" prop="provinceId">
          <el-select v-model="queryParams.provinceId" placeholder="请选择省" @change="chooseProvince" clearable>
            <el-option v-for="item in provinceData" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="市" prop="cityId">
          <el-select v-model="queryParams.cityId" placeholder="请选择市" @change="chooseCity" clearable>
            <el-option v-for="item in cityData" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="区/县" prop="countiesId">
          <el-select v-model="queryParams.countiesId" placeholder="请选择区/县" clearable>
            <el-option v-for="item in areaData" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="活动ID" prop="iaNumber">
          <el-input v-model="queryParams.iaNumber" placeholder="请输入活动ID" clearable />
        </el-form-item>
        <el-form-item label="活动名称" prop="iaName">
          <el-input v-model="queryParams.iaName" placeholder="请输入活动名称" clearable />
        </el-form-item>
        <el-form-item label="活动状态" prop="iaActivityStatus">
          <el-select v-model="queryParams.iaActivityStatus" placeholder="请选择">
            <el-option v-for="item in [
              { value: '0', label: '进行中' },
              { value: '1', label: '已结束' },
            ]" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="创建人" prop="iaCjr">
          <el-input v-model="queryParams.iaCjr" placeholder="请输入创建人" clearable />
        </el-form-item>
        <el-form-item label="创建时间" prop="time">
          <el-date-picker v-model="queryParams.time" value-format="YYYY-MM-DD HH:mm:ss" type="daterange"
            range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
        </el-form-item>
        <!-- <el-form-item label="创建时间" prop="createTime2">
          <el-date-picker value-format="YYYY-MM-DD HH:mm:ss" v-model="queryParams.createTime2" type="datetime"
            placeholder="开始时间" style="width: 212px;" />
        </el-form-item>
        <el-form-item label="安保结束时间" prop="iaFinshTime">
          <el-date-picker value-format="YYYY-MM-DD HH:mm:ss" v-model="queryParams.iaFinshTime" type="datetime"
            placeholder="结束时间" style="width: 192px;" />
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="handleQuery">查询</el-button>
          <el-button @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" @click="addres">添加</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="primary" icon="Delete" :disabled="multiple" @click="delData">删除</el-button>
        </el-col>
        <!-- <right-toolbar v-model:showSearch="showSearch" @queryTable="getListData"></right-toolbar> -->
      </el-row>

      <el-table v-loading="loading" stripe :data="getData" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="活动ID" align="center" prop="iaNumber" />
        <el-table-column label="活动名称" align="center" prop="iaName" width="350">
          <template #default="scope">
            <el-button type="text" @click="updateEnter(scope.row)">{{
              scope.row.iaName
            }}</el-button>
          </template>
        </el-table-column>

        <el-table-column label="省" align="center" prop="iaProvince" />
        <el-table-column label="市" align="center" prop="iaCity" />
        <el-table-column label="区/县" align="center" prop="iaCounties" />

        <el-table-column label="活动状态" align="center" prop="iaActivityStatus">
          <template #default="scope">
            <span v-if="scope.row.iaActivityStatus == '0'">进行中</span>
            <span v-if="scope.row.iaActivityStatus == '1'">已结束</span>
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center" prop="iaCjr" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button type="text" @click="handleEnter(scope.row)">进入</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.page" v-model:limit="queryParams.rows"
        @pagination="getListData" />

      <el-dialog :title="title" v-model="open" width="850px" @close="closeDialog" :close-on-click-modal="false" append-to-body>
        <el-form ref="singleRef" :model="form" :rules="rules" label-width="120px" :scroll-to-error="true">
          <h2 style="text-align: center; color: #0e76d7">
            重大活动安保事件管理
          </h2>
          <el-row>

            <el-col :span="24">
              <el-form-item label="历史安保事件信息查询" label-width="220px">
                <el-select v-model="serch.iaName" filterable remote reserve-keyword placeholder="请输入关键词"
                  style="width: 100%;" :remote-method="remoteMethod" @change="chooseIaName" :loading="serchloading">
                  <el-option v-for="item in serchData" @click="clickIaName(item.iaId)" :key="item.iaId"
                    :label="item.iaName" :value="item.iaId">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!--<el-form-item>
              	
              	
                <div style="display: flex">
                  <el-input
                    class="input"
                    @input="serchig"
                    v-model="serch.iaName"
                    placeholder="历史安保事件信息查询"
                  />
                  <div
                    style="
                      width: 80px;
                      height: 32px;
                      background-color: #107ce5;
                      text-align: center;
                      color: white;
                    "
                  >
                    <el-icon><Search /></el-icon>
                  </div>
                </div>
              </el-form-item>
              <el-form-item>
                <div class="navtab" v-show="isShowTab">
                  <ul class="navwrap">
                    <li
                      @click="searClik(item)"
                      class="tabitem"
                      v-for="(item, index) in serchData"
                      :key="index"
                    >
                      <span>{{ item.iaName }}</span>
                    </li>
                  </ul>
                </div>
              </el-form-item>-->
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="活动ID" prop="iaNumber">
                <el-input v-model="form.iaNumber" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="活动名称" prop="iaName">
                <el-input v-model="form.iaName" type="text" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="活动分类" prop="hdlb">
                <el-select v-model="form.hdlb" placeholder="请选择" style="width:100%">
                  <el-option v-for="item in [{label:'国家级',value:'0'},{label:'省级',value:'1'}]" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="省" prop="provinceId">
                <el-select v-model="form.provinceId" placeholder="请选择" @change="chooseFormProvince" style="width: 100%;">
                  <el-option v-for="item in provinceFormData" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="市" prop="">
                <el-select v-model="form.cityId" placeholder="请选择" @change="chooseFormCity" style="width: 100%;">
                  <el-option v-for="item in cityFormData" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="区/县" prop="">
                <el-select v-model="form.countiesId" placeholder="请选择" style="width: 100%;" @change="chooseFormArea">
                  <el-option v-for="item in areaFormData" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="行政代码" prop="iaCode">
                <el-input v-model="form.iaCode" type="text" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="安保时间" prop="time">
                <el-date-picker value-format="YYYY-MM-DD" v-model="form.time" type="daterange" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" style="width: 100%;" clearable />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <!-- <el-dialog title="请输入" v-model="iSZdmb" width="300px" append-to-body>
              <el-row style="margin: 20px 0;">
                <el-col :span="24">
                  <el-input v-model="form.iaZdmb" type="text" placeholder="请输入" />
                </el-col>
              </el-row>
              <template #footer>
                <div class="dialog-footer">
                  <el-button type="primary" @click="confirmZdmb" style="width: 20px;height: 30px;font-size: 14px;">确 定
                  </el-button>
                  <el-button @click="cancelZdmb" style="width: 20px;height: 30px;font-size: 14px;">取 消</el-button>
                </div>
              </template>
            </el-dialog> -->
            <el-col>
              <el-form-item label="重点目标" prop="iaZdmbs">
                <el-select v-model="form.iaZdmbs" multiple placeholder="请选择重点目标" :disabled="!form.provinceId"
                  @click="getZd" style="width:100%">
                  <el-option v-for="item in optionZd" :key="item.ssId" :label="item.ssJzwmc" :value="item.ssId">
                  </el-option>
                  <template #empty>
                    <div style="padding: 10px 20px;color: #606266">
                      <p>本区域暂无重点场所数据，请在【数据管理】-【重点场所数据管理】 添加。</p>
                      <el-link type="danger" :underline="false" @click="goKeyplace">【前去添加】</el-link>
                    </div>
                  </template>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item label="活动简介" prop="iaHdjj">
                <el-input v-model="form.iaHdjj" type="textarea" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item label="文件通知" prop="iaWjtz">
                <file-upload :action="uploadFileUrl" ref="fileUpload" v-model="form.fileList"
                  :fileType="['pdf', 'ofd', 'doc', 'docx']" @uploadFile="uploadFile" @delFile="delFile" :limit="1" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item>
                <el-button type="primary" @click="taskFg">任务分工</el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <el-dialog title="任务分工" v-model="openFg" width="800px" top="200px" append-to-body>
            <p></p>
            <!-- <el-row>
              <el-col>
                <el-form-item label="文件通知" prop="fileList">
                  <file-upload :action="uploadFileUrl" ref="fileUpload" v-model="form.fileList"
                    :fileType="['pdf', 'ofd', 'doc', 'docx']" @uploadFile="uploadFile" />
                </el-form-item>
              </el-col>
            </el-row> -->
            <el-row>
              <el-col :span="6" class="tab-title">
                监测预报组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="jczDw">
                  <el-input v-model="form.jczDw" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="jczZz">
                  <el-input v-model="form.jczZz" type="text" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="jczCy">
                  <el-input v-model="form.jczCy" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="jczZyzz">
                  <el-input v-model="form.jczZyzz" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="jczGzcs">
                  <el-input v-model="form.jczGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                风险防范组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="fxzDw">
                  <el-input v-model="form.fxzDw" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="fxzZz">
                  <el-input v-model="form.fxzZz" type="text" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="fxzCy">
                  <el-input v-model="form.fxzCy" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="fxzZyzz">
                  <el-input v-model="form.fxzZyzz" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="fxzGzcs">
                  <el-input v-model="form.fxzGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                应急准备组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="yjzDw">
                  <el-input v-model="form.yjzDw" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="yjzZz">
                  <el-input v-model="form.yjzZz" type="text" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="yjzCy">
                  <el-input v-model="form.yjzCy" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="yjzZyzz">
                  <el-input v-model="form.yjzZyzz" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="yjzGzcs">
                  <el-input v-model="form.yjzGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                新闻宣传组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="xwzDw">
                  <el-input v-model="form.xwzDw" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="xwzZz">
                  <el-input v-model="form.xwzZz" type="text" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="xwzCy">
                  <el-input v-model="form.xwzCy" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="xwzZyzz">
                  <el-input v-model="form.xwzZyzz" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="xwzGzcs">
                  <el-input v-model="form.xwzGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                值守信息组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="zszDw">
                  <el-input v-model="form.zszDw" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="zszZz">
                  <el-input v-model="form.zszZz" type="text" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="zszCy">
                  <el-input v-model="form.zszCy" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="zszZyzz">
                  <el-input v-model="form.zszZyzz" type="text" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="zszGzcs">
                  <el-input v-model="form.zszGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" />
                </el-form-item>
              </el-col>
            </el-row>

            <template #footer>
              <div class="dialog-footer">
                <el-button type="primary" @click="openFg = false">确 定</el-button>
                <el-button @click="openFg = false">取 消</el-button>
              </div>
            </template>
          </el-dialog>

          <el-row>
            <el-col :span="12">
              <el-form-item label="指导单位" prop="iaZddw">
                <el-cascader :options="iaZddwData" :key="orgIdZddw" v-model="form.iaZddw" :props="{ multiple: true,emitPath:false, }"
                  :show-all-levels="false" style="width: 100%;" @change="chooseIaZddw" filterable :disabled="enterReview">
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <el-form-item label="业务人员" prop="iaZddwYwry">
                <el-input v-model="form.iaZddwYwry" @click="openSelectUser(2, 'Zddw')" placeholder="请选择业务人员" readonly :class="enterReview?'enterReview':''"
                  style="width: 100%;"/>
              </el-form-item>
            </el-col>
            <!--<el-col :span="3">
              <el-button
                :disabled="form.iaZddwYwry == undefined"
                @click="addMembers"
                >添加
              </el-button>
            </el-col>-->
          </el-row>
          <el-row v-for="(item, index) in zddwYwryList" :key="item.uuid">
            <el-col :span="8">
              <el-form-item label="人员姓名" prop="">
                <el-input v-model="item.realName" type="text" :disabled="enterReview"/>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="任务分工" prop="iaZddwYwryFg" label-width="100px">
                <el-select v-model="item.iaZddwYwryFg" placeholder="请选择" multiple style="width: 100%;" :disabled="enterReview">
                  <el-option v-for="items in rwfgData" :key="items.value" :label="items.label" :value="items.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-button @click="delZddwYwry(index, item)" style="margin-left: 8px;" :disabled="enterReview">删除</el-button>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="实施单位" prop="iaSsdw">
                <el-cascader :options="iaSsdwData" :key="orgIdSsdw" v-model="form.iaSsdw" :props="{ multiple: true, emitPath: false }"
                  :show-all-levels="false" style="width: 100%;" @change="chooseIaSsdw" :disabled="enterReview">
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <el-form-item label="业务人员" prop="iaSsdwYwry">
                <el-input v-model="form.iaSsdwYwry" @click="openSelectUser(2, 'Ssdw')" placeholder="请选择业务人员" readonly :class="enterReview?'enterReview':''"
                  style="width: 100%;" />
              </el-form-item>
            </el-col>
            <!--<el-col :span="3">
              <el-button
                :disabled="form.iaSsdwYwry == undefined"
                @click="addMembers"
                >添加
              </el-button>
            </el-col>-->
          </el-row>
          <el-row v-for="(item, index) in ssdwYwryList" :key="item.uuid">
            <el-col :span="8">
              <el-form-item label="人员姓名" prop="">
                <el-input v-model="item.realName" type="text" :disabled="enterReview"/>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="任务分工" prop="iaSsdwYwryFg" label-width="100px">
                <el-select v-model="item.iaSsdwYwryFg" placeholder="请选择" multiple style="width: 100%;" :disabled="enterReview">
                  <el-option v-for="items in rwfgData" :key="items.value" :label="items.label" :value="items.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-button @click="delSsdwYwry(index, item)" style="margin-left: 8px;" :disabled="enterReview">删除</el-button>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="协同单位" prop="iaXtdw">
                <el-cascader :options="iaXtdwData" v-model="form.iaXtdw" :key="orgIdXtdw" :props="{ multiple: true, emitPath: false }"
                  :show-all-levels="false" style="width: 100%;" @change="chooseIaXtdw" :disabled="enterReview">
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <el-form-item label="业务人员" prop="iaXtdwYwry">
                <el-input v-model="form.iaXtdwYwry" @click="openSelectUser(2, 'Xtdw')" placeholder="请选择业务人员" readonly
                  style="width: 100%;" :class="enterReview?'enterReview':''"/>
              </el-form-item>
            </el-col>
            <!--<el-col :span="3">
              <el-button
                :disabled="form.iaXtdwYwry == undefined"
                @click="addMembers"
                >添加
              </el-button>
            </el-col>-->
          </el-row>
          <el-row v-for="(item, index) in xtdwYwryList" :key="item.uuid">
            <el-col :span="8">
              <el-form-item label="人员姓名" prop="">
                <el-input v-model="item.realName" type="text" :disabled="enterReview"/>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="任务分工" prop="iaXtdwYwryFg" label-width="100px">
                <el-select v-model="item.iaXtdwYwryFg" placeholder="请选择" multiple style="width: 100%;" :disabled="enterReview">
                  <el-option v-for="items in rwfgData" :key="items.value" :label="items.label" :value="items.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-button @click="delXtdwYwry(index, item)" style="margin-left: 8px;" :disabled="enterReview">删除</el-button>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="初步审核" prop="iaCbsh">
                <el-input v-model="form.iaCbsh" type="text" readonly placeholder="请选择人员"
                  @click="openSelectUser(1, 'Cbsh')" :disabled="enterReview"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="部门审核" prop="iaBmsh">
                <el-input v-model="form.iaBmsh" type="text" readonly placeholder="请选择人员"
                  @click="openSelectUser(1, 'Bmsh')" :disabled="enterReview"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="领导审核" prop="iaLdsh">
                <el-input v-model="form.iaLdsh" type="text" readonly placeholder="请选择人员"
                  @click="openSelectUser(1, 'Ldsh')" :disabled="enterReview"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="创建人" prop="iaCjr">
                <el-input v-model="form.iaCjr" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建人单位" prop="iaCjrDw">
                <el-input v-model="form.iaCjrDw" type="text" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="联系方式" prop="iaLxfs">
                <el-input v-model="form.iaLxfs" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="iaEmail">
                <el-input v-model="form.iaEmail" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="创建日期" prop="createTime2">
                <el-date-picker v-model="form.createTime2" type="date" value-format="YYYY-MM-DD" placeholder="请选择创建日期"
                  style="width: 100%;" disabled />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitForm">保存</el-button>
            <el-button type="primary" @click="closeForm">关闭</el-button>
          </div>
        </template>
      </el-dialog>
      <!-- 人员选择对话框 -->
      <el-dialog v-model="show" width="1200px" append-to-body>
        <template #title>
          人员选择<span v-show="isshow != 1">（多选）</span><span v-show="isshow == 1">（单选）</span>
        </template>
        <select-user ref="selectRef" :isshow="isshow" @getSelectList="getSelectList" />
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="ok">确 定</el-button>
            <el-button @click="cancelP">取 消</el-button>
          </div>
        </template>
      </el-dialog>
      <el-dialog title="历史安保事件" v-model="openCheck" width="850px" append-to-body>
        <el-form :model="checkForm" label-width="120px">

          <h2 style="text-align: center; color: #0e76d7">
            {{ checkForm.iaName }}
          </h2>
          <el-row>
            <el-col :span="12">
              <h3>活动ID:{{ checkForm.iaNumber }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>活动分类:{{ checkForm.hdlb=='0'?'国家级':'省级' }}</h3>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <h3>省:{{ checkForm.iaProvince }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>市:{{ checkForm.iaCity }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>区/县:{{ checkForm.iaCounties }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>行政代码:{{ checkForm.iaCode }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>安保开始时间:{{ checkForm.iaStartingTime }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>安保结束时间:{{ checkForm.iaFinshTime }}</h3>
            </el-col>
          </el-row>
          <!--<el-row>
            <el-col>
              <h3>任务分工:{{ checkForm.iaAsses }}</h3>
            </el-col>
          </el-row>-->
          <el-row>
            <el-col>
              <h3>重点目标:{{ checkForm.iaZdmb }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>活动简介:{{ checkForm.iaHdjj }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>文件通知:{{ checkForm.fileList[0].attachName }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item>
                <el-button type="primary" @click="taskFg1">任务分工</el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <el-dialog title="任务分工" v-model="openFg1" width="800px" top="200px" append-to-body>
            <p></p>
            <!-- <el-row>
              <el-col>
                <el-form-item label="文件通知">
                  <file-upload :action="uploadFileUrl" ref="fileUpload" v-model="checkForm.fileList" />
                </el-form-item>
              </el-col>
            </el-row> -->
            <el-row>
              <el-col :span="6" class="tab-title">
                监测预报组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="checkForm.jczDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="checkForm.jczZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="checkForm.jczCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="checkForm.jczZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="checkForm.jczGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                风险防范组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="checkForm.fxzDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="checkForm.fxzZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="checkForm.fxzCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="checkForm.fxzZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="checkForm.fxzGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                应急准备组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="checkForm.yjzDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="checkForm.yjzZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="checkForm.yjzCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="checkForm.yjzZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="checkForm.yjzGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                新闻宣传组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="checkForm.xwzDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="checkForm.xwzZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="checkForm.xwzCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="checkForm.xwzZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="checkForm.xwzGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                值守信息组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="checkForm.zszDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="checkForm.zszZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="checkForm.zszCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="checkForm.zszZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="checkForm.zszGzcs" type="textarea" :rows="5" show-word-limit maxlength="1500" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <template #footer>
              <div class="dialog-footer">
                <el-button @click="openFg1 = false">取 消</el-button>
              </div>
            </template>
          </el-dialog>
          <el-row>
            <el-col>
              <h3 style="display: inline-block;">指导单位:</h3>
              <!-- {{ checkForm.iaZddw }}
              {{ iaZddwData }} -->
              <!-- <el-cascader :options="iaZddwData" v-model="checkForm.iaZddw" :props="{ checkStrictly: true }"
                :show-all-levels="false" filterable style="display: inline-block;" disabled>
              </el-cascader> -->
              <el-cascader :options="iaZddwData" v-model="checkForm.iaZddw" :props="{ multiple: true, emitPath: false }"
                  :show-all-levels="false" :emitPath="false" style="display: inline-block;" filterable disabled>
                </el-cascader>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>业务人员:{{ checkForm.iaZddwYwry }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3 style="display: inline-block;">实施单位:</h3>
              <el-cascader :options="iaSsdwData" v-model="checkForm.iaSsdw" :props="{  multiple: true, emitPath: false }"
                :show-all-levels="false" :emitPath="false" filterable style="display: inline-block;" disabled>
              </el-cascader>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>业务人员:{{ checkForm.iaSsdwYwry }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3 style="display: inline-block;">协同单位:</h3>
              <el-cascader :options="iaXtdwData" v-model="checkForm.iaXtdw" :props="{ multiple: true, emitPath: false }"
                :show-all-levels="false" :emitPath="false" filterable style="display: inline-block;" disabled>
              </el-cascader>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>业务人员:{{ checkForm.iaXtdwYwry }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>初步审核:{{ checkForm.iaCbsh }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>部门审核:{{ checkForm.iaBmsh }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>领导审核:{{ checkForm.iaLdsh }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>创建人:{{ checkForm.iaCjr }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>创建人单位:{{ checkForm.iaCjrDw }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>联系方式:{{ checkForm.iaLxfs }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>邮箱:{{ checkForm.iaEmail }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>创建日期:{{ checkForm.createTime2 }}</h3>
            </el-col>
          </el-row>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="toLeadForm">导入</el-button>
            <el-button type="primary" @click="closeForm1">关闭</el-button>
          </div>
        </template>
      </el-dialog>
    </div>
  </div>
</template>
  
<script setup name="activities">
import selectUser from "./selectUser";
import useUserStore from '@/store/modules/user';

import {
  getList,
  delList,
  saveList,
  updateList,
  serchList,
  getImport,
  getName,
  getDw,
  getActivityIdList,
  getZdmb,
  getAdmin,
  isEnterReview,
} from "@/api/business/activities";
import { getProvince, getChildArea, getDivisionCode } from "@/api/system/division";
import { nextTick, onActivated } from "vue-demi";

const { proxy } = getCurrentInstance();
const uploadFileUrl = ref(
  import.meta.env.VITE_APP_BASE_API + "/attachment/uploadFile"
); // 上传的图片服务器地址
const userStore = useUserStore();
const openCheck = ref(false);
const openFg = ref(false);
const openFg1 = ref(false);
const iSZdmb = ref(false);
const serchData = ref([]);
const iaZddwData = ref([]);
const iaSsdwData = ref([]);
const iaXtdwData = ref([]);
const rwfgData = ref([{ label: '地震环境及监测能力分析', value: '地震环境及监测能力分析' }, { label: '房屋地震灾害分析评估', value: '房屋地震灾害分析评估' }, { label: '地震灾害风险排查及建议', value: '地震灾害风险排查及建议' }])
const zddwYwryList = ref([]);
const zddwYwrys = ref([]);
const ssdwYwryList = ref([]);
const ssdwYwrys = ref([]);
const xtdwYwryList = ref([]);
const xtdwYwrys = ref([]);
const iaZdmbList = ref([]);
const loading = ref(true);
const serchloading = ref(false);
const isEditFile = ref(false);
const props = {
    multiple: true, emitPath: false
}
const value = ref(['2f655e3a6b75424dae18c5ab57ed1360'])

const provinceData = ref([]); //省
const cityData = ref([]); //市
const areaData = ref([]); //区、县
const total = ref(0);
const title = ref(""); //标题
const open = ref(false); //新增dialog操作
const getData = ref([]); //获取列表数组
const dateRange = ref([]);
const uniqueId = ref("");
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const control = ref(true);
const isshow = ref(undefined);
const isDw = ref(undefined);
const show = ref(false);
const time = ref();
const orgIdZddw = ref('');
const orgIdSsdw = ref('');
const orgIdXtdw = ref('');
const rwmc = ref('');
const isShowTime = ref(true);
const isShowTab = ref(false);
const provinceFormData = ref([]);//表单省 
const cityFormData = ref([]);//表单市
const areaFormData = ref([]);//表单区、县
const optionZd = ref([]);//重点目标
const router = useRouter();
const route = useRoute();
const validateInput = (rule, value, callback) => {
      if (checkSpecialKey(value)) {
        callback(new Error("不能含有特殊字符 / "));
      } else {
        callback();
      }
    }
const data = reactive({
  form: {},
  queryParams: {
    page: 1,
    rows: 10,
    provinceId: null,
    cityId: null,
    countiesId: null,
    iaNumber: null,
    iaName: null,
    hdlb: null,
    iaActivityStatus: null,
    iaCjr: null,
    time: null,
    iaFinshTime: null,
    createTime2: null,
  },
  serch: {
    iaName: null,
  },
  checkForm: {},
  rules: {
    provinceId: [{ required: true, message: "省不能为空", trigger: "change" }],
    cityId: [{ required: true, message: "市不能为空", trigger: "change" }],
    countiesId: [{ required: true, message: "县不能为空", trigger: "change" }],
    iaNumber: [{ required: true, message: "活动ID不能为空", trigger: "blur" }],
    iaName: [{ required: true, message: "活动名称不能为空", trigger: ['blur', 'change'],validator: validateInput, }],
    hdlb: [{ required: true, message: "活动分类不能为空", trigger: "blur" }],
    time: [
      { required: true, message: "时间不能为空", trigger: "blur" },
    ],
    iaStartingTime: [
      { required: true, message: "开始时间不能为空", trigger: "blur" },
    ],
    iaFinshTime: [
      { required: true, message: "结束时间不能为空", trigger: "blur" },
    ],
    iaZdmbs: [{ required: true, message: "重点目标不能为空", trigger: "blur" }],
    //iaZdmb: [{ required: true, message: "重点目标不能为空", trigger: "blur" }],
    iaWjtz: [{ required: true, message: "文件通知不能为空", trigger: "blur" }],
    iaZddw: [{ required: true, message: "指导单位不能为空", trigger: "change" }],
    iaZddwYwry: [{ required: true, message: "指导单位业务人员不能为空", trigger: "change" }],
    rwmc: [{ required: true, message: "活动分类不能为空", trigger: "change" }],
    iaSsdw: [{ required: true, message: "实施单位不能为空", trigger: "change" }],
    iaSsdwYwry: [{ required: true, message: "实施单位业务人员不能为空", trigger: "change" }],
    iaXtdw: [{ required: true, message: "协同单位不能为空", trigger: "change" }],
    iaXtdwYwry: [{ required: true, message: "协同单位业务人员不能为空", trigger: "change" }],
    iaCbsh: [{ required: true, message: "初步审核不能为空", trigger: "change" }],
    iaBmsh: [{ required: true, message: "部门审核不能为空", trigger: "change" }],
    iaLdsh: [{ required: true, message: "领导审核不能为空", trigger: "change" }],
    iaLxfs: [{ required: true, message: "联系方式不能为空", trigger: "blur" }],
  },
});
const { queryParams, form, rules, serch, checkForm } = toRefs(data);

function checkSpecialKey(str) {
      if(str&&str.includes('/')){
        return true;
      }else{
        return false
      }
    }

function editProvinceFormData(provinceId, cityId) {
  getProvince().then(response => {
    provinceFormData.value = response.data;
  });
  getChildArea(provinceId).then(response => {
    cityFormData.value = response.data;
  });
  getChildArea(cityId).then(response => {
    areaFormData.value = response.data;
  });
}

function chooseFormProvince(value) {
  form.value.iaZdmbs = [];
  form.value.cityId = null;
  form.value.countiesId = null;
  cityFormData.value = [];
  areaFormData.value = [];
  getChildArea(value).then(response => {
    cityFormData.value = response.data;
  });
  getDivisionCode(value).then(response => {
    form.value.iaCode = response.data;
  });

}

function chooseProvince(value) {
  queryParams.value.cityId = null;
  queryParams.value.countiesId = null;
  cityData.value = [];
  areaData.value = [];
  getChildArea(value).then(response => {
    cityData.value = response.data;
  });
  //queryParams.value.city = null;
  //queryParams.value.county = null;
  //cityData.value = [];
  //areaData.value = [];
  //provinceData.value.map((item) => {
  //  //遍历数据
  //  if (item.id == value) {
  //    if (
  //      item.name == "北京市" ||
  //      item.name == "天津市" ||
  //      item.name == "上海市" ||
  //      item.name == "重庆市"
  //    ) {
  //      cityData.value.push(JSON.parse(JSON.stringify(item)));
  //    } else {
  //      getChildArea(value).then((response) => {
  //        cityData.value = response.data;
  //      });
  //    }
  //    return;
  //  }
  //});
}

function chooseCity(value) {
  queryParams.value.countiesId = null;
  areaData.value = [];
  getChildArea(value).then((response) => {
    areaData.value = response.data;
  });
}

function chooseFormCity(value) {
  form.value.iaZdmbs = [];
  form.value.countiesId = null;
  areaFormData.value = [];
  getChildArea(value).then(response => {
    areaFormData.value = response.data;
  });
  getDivisionCode(value).then(response => {
    form.value.iaCode = response.data;
  });
}
function chooseFormArea(value) {
  form.value.iaZdmbs = [];
  getDivisionCode(value).then(response => {
    form.value.iaCode = response.data;
  });
}

/** 获取省列表 */
function getProvinceData() {
  getProvince().then((response) => {
    provinceData.value = response.data;
    provinceFormData.value = response.data;
  });
}

/** 获取单位 */
function getDwData() {
  getDw().then((response) => {
    response.data.forEach((item)=>{
      if(item.label=='中国地震灾害防御中心'){
        delete  item.children
      }
    })
    iaZddwData.value = response.data;
    iaSsdwData.value = response.data;
    iaXtdwData.value = response.data;
  });
}

onActivated(() => {
  const time = route.query.t;
  if (time != null && time != uniqueId.value) {
    uniqueId.value = time;
    queryParams.value.page = Number(route.query.page);
    proxy.resetForm("queryRef");
    getListData();
  }
});

// 获取列表
function getListData() {
  loading.value = true;
  getList({ ...queryParams.value, createTime2: queryParams.value.time ? queryParams.value.time[0] : null, iaFinshTime: queryParams.value.time ? queryParams.value.time[1] : null }).then((res) => {
    // const rows = res.data.rows.slice((queryParams.value.page - 1) * queryParams.value.rows, queryParams.value.page * queryParams.value.rows)
    getData.value = res.data.rows?res.data.rows:[];
    total.value = res.data.total;
    loading.value = false;
  });
}

//获取当前时间
function getNowFormatDate() {
  let date = new Date(),
    seperator1 = '-', //格式分隔符
    year = date.getFullYear(), //获取完整的年份(4位)
    month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
    strDate = date.getDate() // 获取当前日(1-31)
  if (month >= 1 && month <= 9) month = '0' + month // 如果月份是个位数，在前面补0
  if (strDate >= 0 && strDate <= 9) strDate = '0' + strDate // 如果日是个位数，在前面补0

  let currentdate = year + seperator1 + month + seperator1 + strDate
  return currentdate
}

//获取活动ID
function getImportantActivityId() {
  getActivityIdList().then((res) => {
    form.value.iaNumber = res.data.nextSerialNo;
  });
}

//添加操作
function addres() {
  reset();
  proxy.resetForm("singleRef");
  //isShowTime.value = true;
  cityFormData.value = [];
  areaFormData.value = [];
  zddwYwryList.value = [];
  ssdwYwryList.value = [];
  xtdwYwryList.value = [];
  form.value.iaCjr = userStore.name;
  //form.value.createTime2 = getNowFormatDate();
  form.value.createTime2 = getNowFormatDate();
  form.value.iaCjrDw = localStorage.getItem("orgName");

  getImportantActivityId();
  open.value = true;
  title.value = "重大安保事件管理";
}

function closeForm1() {
  openCheck.value = false;
  // reset();
}

//关闭表单操作
function closeForm() {
  open.value = false;
  // isShowTab.value = false;
}

// 查询
function handleQuery() {
  queryParams.page = 1;
  getListData();
}
// 重置
function resetQuery() {
  dateRange.value = [];
  proxy.resetForm("queryRef");
  getListData();
}

//复选框操作
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.iaId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

// 删除
function delData() {
  proxy.$modal
    .confirm(
      "该操作会删除选中的重大安保服务活动的所有数据（包含活动信息、评估结果和负责对策信息结果），是否确定删除？"
    )
    .then(function () {
      return delList(ids.value.join(","));
    })
    .then(() => {
      getListData();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => { });
}

//修改操作
const enterReview = ref(false);
function updateEnter(row) {
  reset();
  const id = row.iaId
  zddwYwryList.value = []
  ssdwYwryList.value = []
  xtdwYwryList.value = []
  isEditFile.value = false;
  isEnterReview({iaId:id}).then(res=>{
    enterReview.value = res.data == '1'
  })
  getImport(id).then(response => {
    form.value = response.data.importantActivity;
    form.value.time = [response.data.importantActivity.iaStartingTime, response.data.importantActivity.iaFinshTime];
    form.value.fileList = response.data.list;
    editProvinceFormData(response.data.importantActivity.provinceId, response.data.importantActivity.cityId);
    if (response.data.importantActivity.zdmbs != null) {
      form.value.iaZdmbs = response.data.importantActivity.zdmbs;
    }

    orgIdZddw.value = response.data.importantActivity.iaZddw;
    orgIdSsdw.value = response.data.importantActivity.iaSsdw;
    orgIdXtdw.value = response.data.importantActivity.iaXtdw;
    rwmc.value = response.data.importantActivity.rwmc;
    form.value.iaZddw = response.data.importantActivity.iaZddw.split(',')
    form.value.iaSsdw = response.data.importantActivity.iaSsdw.split(',')
    form.value.iaXtdw = response.data.importantActivity.iaXtdw.split(',')
    // form.value.rwmc = response.data.importantActivity.rwmc.split(',')
    form.value.rwmc = [];

    if (response.data.importantActivity.zddwYwrys != null && response.data.importantActivity.zddwYwrys != '') {
      response.data.importantActivity.zddwYwrys.forEach((item) => {
        zddwYwryList.value.push({
          "uuid": item.id,
          "realName": item.name,
          "iaZddwYwryFg": item.duties
        });
      });
    }
    if (response.data.importantActivity.ssdwYwrys != null && response.data.importantActivity.ssdwYwrys != '') {
      response.data.importantActivity.ssdwYwrys.forEach((item) => {
        ssdwYwryList.value.push({
          "uuid": item.id,
          "realName": item.name,
          "iaSsdwYwryFg": item.duties
        });
      });
    }
    if (response.data.importantActivity.xtdwYwrys != null && response.data.importantActivity.xtdwYwrys != '') {
      response.data.importantActivity.xtdwYwrys.forEach((item) => {
        xtdwYwryList.value.push({
          "uuid": item.id,
          "realName": item.name,
          "iaXtdwYwryFg": item.duties
        });
      });
    }

    open.value = true;
    title.value = "修改重大安保事件管理";
  });
  //open.value = true;
  //isShowTime.value = true;
  //title.value = "修改重大安保事件管理";
  //form.value.iaId = row.iaId;
  //form.value.iaNumber = row.iaNumber;
  //form.value.iaName = row.iaName;
  //
  //form.value.provinceId = row.iaProvince;
  //form.value.cityId = row.iaCity;
  //form.value.countiesId = row.iaCounties;
  //
  //form.value.iaCode = row.iaCode;
  //form.value.iaStartingTime = row.iaStartingTime;
  //form.value.iaFinshTime = row.iaFinshTime;
  //form.value.iaAsses = row.iaAsses;
  //form.value.iaZdmb = row.iaZdmb;
  //form.value.iaWjtz = row.iaWjtz;
  //form.value.iaHdjj = row.iaHdjj;
  //form.value.iaZddw = row.iaZddw;
  //form.value.iaZddwYwry = row.iaZddwYwry;
  //form.value.iaSsdw = row.iaSsdw;
  //form.value.iaSsdwYwry = row.iaSsdwYwry;
  //form.value.iaXtdw = row.iaXtdw;
  //form.value.iaXtdwYwry = row.iaXtdwYwry;
  //form.value.iaCbsh = row.iaCbsh;
  //form.value.iaBmsh = row.iaBmsh;
  //form.value.iaLdsh = row.iaLdsh;
  //form.value.iaCjr = row.iaCjr;
  //form.value.iaCjrDw = row.iaCjrDw;
  //form.value.iaLxfs = row.iaLxfs;
  //form.value.iaEmail = row.iaEmail;
  //form.value.createTime2 = row.createTime2;
}

function transformYwry() {
  zddwYwrys.value = [];
  ssdwYwrys.value = [];
  xtdwYwrys.value = [];

  zddwYwryList.value.forEach((item) => {
    zddwYwrys.value.push({
      "id": item.uuid,
      "name": item.realName,
      "duties": item.iaZddwYwryFg
    });
  });
  ssdwYwryList.value.forEach((item) => {
    ssdwYwrys.value.push({
      "id": item.uuid,
      "name": item.realName,
      "duties": item.iaSsdwYwryFg
    });
  });
  xtdwYwryList.value.forEach((item) => {
    xtdwYwrys.value.push({
      "id": item.uuid,
      "name": item.realName,
      "duties": item.iaXtdwYwryFg
    });
  });
}


//保存
async function submitForm() {
  transformYwry()
  const fileList = proxy.$refs["fileUpload"] ? JSON.parse(
    JSON.stringify(proxy.$refs["fileUpload"].fileList)
  ) : [];
  const attachIds = [];
  for (var i = 0; i < fileList.length; i++) {
    attachIds.push(fileList[i].attachId);
  }
  form.value.iaWjtz = attachIds.join(",");
  let valid = await proxy.$refs.singleRef.validate()
  console.log(valid, form.value.fileList)
  if (!valid) return
  if (title.value != "修改重大安保事件管理") {
    saveList({
      iaNumber: form.value.iaNumber,
      iaName: form.value.iaName,
      hdlb: form.value.hdlb,
      provinceId: form.value.provinceId,
      cityId: form.value.cityId,
      countiesId: form.value.countiesId,
      iaCode: form.value.iaCode,
      iaStartingTime: getTime(form.value.time[0]),
      iaFinshTime: getTime(form.value.time[1]),
      zdmbs: form.value.iaZdmbs,
      iaWjtz: form.value.iaWjtz,
      jczDw: form.value.jczDw,
      jczZz: form.value.jczZz,
      jczCy: form.value.jczCy,
      jczZyzz: form.value.jczZyzz,
      jczGzcs: form.value.jczGzcs,

      fxzDw: form.value.fxzDw,
      fxzZz: form.value.fxzZz,
      fxzCy: form.value.fxzCy,
      fxzZyzz: form.value.fxzZyzz,
      fxzGzcs: form.value.fxzGzcs,

      yjzDw: form.value.yjzDw,
      yjzZz: form.value.yjzZz,
      yjzCy: form.value.yjzCy,
      yjzZyzz: form.value.yjzZyzz,
      yjzGzcs: form.value.yjzGzcs,

      yjzDw: form.value.yjzDw,
      yjzZz: form.value.yjzZz,
      yjzCy: form.value.yjzCy,
      yjzZyzz: form.value.yjzZyzz,
      yjzGzcs: form.value.yjzGzcs,

      yjzDw: form.value.yjzDw,
      yjzZz: form.value.yjzZz,
      yjzCy: form.value.yjzCy,
      yjzZyzz: form.value.yjzZyzz,
      yjzGzcs: form.value.yjzGzcs,

      xwzDw: form.value.xwzDw,
      xwzZz: form.value.xwzZz,
      xwzCy: form.value.xwzCy,
      xwzZyzz: form.value.xwzZyzz,
      xwzGzcs: form.value.xwzGzcs,

      zszDw: form.value.zszDw,
      zszZz: form.value.zszZz,
      zszCy: form.value.zszCy,
      zszZyzz: form.value.zszZyzz,
      zszGzcs: form.value.zszGzcs,

      iaHdjj: form.value.iaHdjj,

      iaZddw: Array.isArray(form.value.iaZddw) ? form.value.iaZddw.join(',') : form.value.iaZddw,
      zddwYwrys: JSON.parse(JSON.stringify(zddwYwrys.value)),

      iaSsdw: Array.isArray(form.value.iaSsdw) ? form.value.iaSsdw.join(',') : form.value.iaSsdw,
      ssdwYwrys: JSON.parse(JSON.stringify(ssdwYwrys.value)),

      iaXtdw: Array.isArray(form.value.iaXtdw) ? form.value.iaXtdw.join(',') : form.value.iaXtdw,
      xtdwYwrys: JSON.parse(JSON.stringify(xtdwYwrys.value)),

      iaAsses: form.value.iaAsses,
      //iaZdmb: form.value.iaZdmb,


      iaZddwYwry: form.value.iaZddwYwry,

      iaSsdwYwry: form.value.iaSsdwYwry,

      iaXtdwYwry: form.value.iaXtdwYwry,
      iaCbsh: form.value.iaCbsh,
      iaBmsh: form.value.iaBmsh,
      iaLdsh: form.value.iaLdsh,
      cbshId: form.value.cbshId,
      bmshId: form.value.bmshId,
      ldshId: form.value.ldshId,
      iaCjr: form.value.iaCjr,
      iaCjrDw: form.value.iaCjrDw,
      iaLxfs: form.value.iaLxfs,
      iaEmail: form.value.iaEmail,
    }).then((res) => {
      open.value = false;
      proxy.$modal.msgSuccess("新增成功");
      reset();
      getListData();
    });
  } else {
    updateList({
      iaId: form.value.iaId,
      iaNumber: form.value.iaNumber,
      iaName: form.value.iaName,
      hdlb: form.value.hdlb,
      provinceId: form.value.provinceId,
      cityId: form.value.cityId,
      countiesId: form.value.countiesId,
      iaCode: form.value.iaCode,
      iaStartingTime: getTime(form.value.time[0]),
      iaFinshTime: getTime(form.value.time[1]),
      zdmbs: form.value.iaZdmbs,
      iaWjtz: form.value.iaWjtz,
      jczDw: form.value.jczDw,
      jczZz: form.value.jczZz,
      jczCy: form.value.jczCy,
      jczZyzz: form.value.jczZyzz,
      jczGzcs: form.value.jczGzcs,

      fxzDw: form.value.fxzDw,
      fxzZz: form.value.fxzZz,
      fxzCy: form.value.fxzCy,
      fxzZyzz: form.value.fxzZyzz,
      fxzGzcs: form.value.fxzGzcs,

      yjzDw: form.value.yjzDw,
      yjzZz: form.value.yjzZz,
      yjzCy: form.value.yjzCy,
      yjzZyzz: form.value.yjzZyzz,
      yjzGzcs: form.value.yjzGzcs,

      yjzDw: form.value.yjzDw,
      yjzZz: form.value.yjzZz,
      yjzCy: form.value.yjzCy,
      yjzZyzz: form.value.yjzZyzz,
      yjzGzcs: form.value.yjzGzcs,

      yjzDw: form.value.yjzDw,
      yjzZz: form.value.yjzZz,
      yjzCy: form.value.yjzCy,
      yjzZyzz: form.value.yjzZyzz,
      yjzGzcs: form.value.yjzGzcs,

      xwzDw: form.value.xwzDw,
      xwzZz: form.value.xwzZz,
      xwzCy: form.value.xwzCy,
      xwzZyzz: form.value.xwzZyzz,
      xwzGzcs: form.value.xwzGzcs,

      zszDw: form.value.zszDw,
      zszZz: form.value.zszZz,
      zszCy: form.value.zszCy,
      zszZyzz: form.value.zszZyzz,
      zszGzcs: form.value.zszGzcs,

      iaHdjj: form.value.iaHdjj,

      iaZddw: Array.isArray(form.value.iaZddw) ? form.value.iaZddw.join(',') : form.value.iaZddw,
      zddwYwrys: JSON.parse(JSON.stringify(zddwYwrys.value)),

      iaSsdw: Array.isArray(form.value.iaSsdw) ? form.value.iaSsdw.join(',') : form.value.iaSsdw,
      ssdwYwrys: JSON.parse(JSON.stringify(ssdwYwrys.value)),

      iaXtdw: Array.isArray(form.value.iaXtdw) ? form.value.iaXtdw.join(',') : form.value.iaXtdw,
      xtdwYwrys: JSON.parse(JSON.stringify(xtdwYwrys.value)),

      iaAsses: form.value.iaAsses,
      //iaZdmb: form.value.iaZdmb,


      iaZddwYwry: form.value.iaZddwYwry,

      iaSsdwYwry: form.value.iaSsdwYwry,

      iaXtdwYwry: form.value.iaXtdwYwry,
      iaCbsh: form.value.iaCbsh,
      iaBmsh: form.value.iaBmsh,
      iaLdsh: form.value.iaLdsh,
      cbshId: form.value.cbshId,
      bmshId: form.value.bmshId,
      ldshId: form.value.ldshId,
      iaCjr: form.value.iaCjr,
      iaCjrDw: form.value.iaCjrDw,
      iaLxfs: form.value.iaLxfs,
      iaEmail: form.value.iaEmail,
      createTime2: form.value.createTime2,
    }).then((res) => {
      open.value = false;
      proxy.$modal.msgSuccess("修改成功");
      getListData();
    });
  }

  // proxy.$refs.singleRef.validate((vaild) => {
  //   console.log(vaild)
  //   if (!vaild) {
  //     return;
  //   }
  //   if (title.value != "修改重大安保事件管理") {
  //     saveList({
  //       iaNumber: form.value.iaNumber,
  //       iaName: form.value.iaName,
  //       provinceId: form.value.provinceId,
  //       cityId: form.value.cityId,
  //       countiesId: form.value.countiesId,
  //       iaCode: form.value.iaCode,
  //       iaStartingTime: getTime(form.value.time[0]),
  //       iaFinshTime: getTime(form.value.time[1]),
  //       zdmbs: form.value.iaZdmbs,
  //       iaWjtz: form.value.iaWjtz,
  //       jczDw: form.value.jczDw,
  //       jczZz: form.value.jczZz,
  //       jczCy: form.value.jczCy,
  //       jczZyzz: form.value.jczZyzz,
  //       jczGzcs: form.value.jczGzcs,

  //       fxzDw: form.value.fxzDw,
  //       fxzZz: form.value.fxzZz,
  //       fxzCy: form.value.fxzCy,
  //       fxzZyzz: form.value.fxzZyzz,
  //       fxzGzcs: form.value.fxzGzcs,

  //       yjzDw: form.value.yjzDw,
  //       yjzZz: form.value.yjzZz,
  //       yjzCy: form.value.yjzCy,
  //       yjzZyzz: form.value.yjzZyzz,
  //       yjzGzcs: form.value.yjzGzcs,

  //       yjzDw: form.value.yjzDw,
  //       yjzZz: form.value.yjzZz,
  //       yjzCy: form.value.yjzCy,
  //       yjzZyzz: form.value.yjzZyzz,
  //       yjzGzcs: form.value.yjzGzcs,

  //       yjzDw: form.value.yjzDw,
  //       yjzZz: form.value.yjzZz,
  //       yjzCy: form.value.yjzCy,
  //       yjzZyzz: form.value.yjzZyzz,
  //       yjzGzcs: form.value.yjzGzcs,

  //       xwzDw: form.value.xwzDw,
  //       xwzZz: form.value.xwzZz,
  //       xwzCy: form.value.xwzCy,
  //       xwzZyzz: form.value.xwzZyzz,
  //       xwzGzcs: form.value.xwzGzcs,

  //       zszDw: form.value.zszDw,
  //       zszZz: form.value.zszZz,
  //       zszCy: form.value.zszCy,
  //       zszZyzz: form.value.zszZyzz,
  //       zszGzcs: form.value.zszGzcs,

  //       iaHdjj: form.value.iaHdjj,

  //       iaZddw: form.value.iaZddw.join(','),
  //       zddwYwrys: JSON.parse(JSON.stringify(zddwYwrys.value)),

  //       iaSsdw: form.value.iaSsdw.join(','),
  //       ssdwYwrys: JSON.parse(JSON.stringify(ssdwYwrys.value)),

  //       iaXtdw: form.value.iaXtdw.join(','),
  //       xtdwYwrys: JSON.parse(JSON.stringify(xtdwYwrys.value)),

  //       iaAsses: form.value.iaAsses,
  //       //iaZdmb: form.value.iaZdmb,


  //       iaZddwYwry: form.value.iaZddwYwry,

  //       iaSsdwYwry: form.value.iaSsdwYwry,

  //       iaXtdwYwry: form.value.iaXtdwYwry,
  //       iaCbsh: form.value.iaCbsh,
  //       iaBmsh: form.value.iaBmsh,
  //       iaLdsh: form.value.iaLdsh,
  //       cbshId: form.value.cbshId,
  //       bmshId: form.value.bmshId,
  //       ldshId: form.value.ldshId,
  //       iaCjr: form.value.iaCjr,
  //       iaCjrDw: form.value.iaCjrDw,
  //       iaLxfs: form.value.iaLxfs,
  //       iaEmail: form.value.iaEmail,
  //     }).then((res) => {
  //       open.value = false;
  //       proxy.$modal.msgSuccess("新增成功");
  //       // reset();
  //       getListData();
  //     });
  //   } else {
  //     updateList({
  //       iaId: form.value.iaId,
  //       iaNumber: form.value.iaNumber,
  //       iaName: form.value.iaName,
  //       provinceId: form.value.provinceId,
  //       cityId: form.value.cityId,
  //       countiesId: form.value.countiesId,
  //       iaCode: form.value.iaCode,
  //       iaStartingTime: getTime(form.value.time[0]),
  //       iaFinshTime: getTime(form.value.time[1]),
  //       zdmbs: form.value.iaZdmbs,
  //       iaWjtz: form.value.iaWjtz,
  //       jczDw: form.value.jczDw,
  //       jczZz: form.value.jczZz,
  //       jczCy: form.value.jczCy,
  //       jczZyzz: form.value.jczZyzz,
  //       jczGzcs: form.value.jczGzcs,

  //       fxzDw: form.value.fxzDw,
  //       fxzZz: form.value.fxzZz,
  //       fxzCy: form.value.fxzCy,
  //       fxzZyzz: form.value.fxzZyzz,
  //       fxzGzcs: form.value.fxzGzcs,

  //       yjzDw: form.value.yjzDw,
  //       yjzZz: form.value.yjzZz,
  //       yjzCy: form.value.yjzCy,
  //       yjzZyzz: form.value.yjzZyzz,
  //       yjzGzcs: form.value.yjzGzcs,

  //       yjzDw: form.value.yjzDw,
  //       yjzZz: form.value.yjzZz,
  //       yjzCy: form.value.yjzCy,
  //       yjzZyzz: form.value.yjzZyzz,
  //       yjzGzcs: form.value.yjzGzcs,

  //       yjzDw: form.value.yjzDw,
  //       yjzZz: form.value.yjzZz,
  //       yjzCy: form.value.yjzCy,
  //       yjzZyzz: form.value.yjzZyzz,
  //       yjzGzcs: form.value.yjzGzcs,

  //       xwzDw: form.value.xwzDw,
  //       xwzZz: form.value.xwzZz,
  //       xwzCy: form.value.xwzCy,
  //       xwzZyzz: form.value.xwzZyzz,
  //       xwzGzcs: form.value.xwzGzcs,

  //       zszDw: form.value.zszDw,
  //       zszZz: form.value.zszZz,
  //       zszCy: form.value.zszCy,
  //       zszZyzz: form.value.zszZyzz,
  //       zszGzcs: form.value.zszGzcs,

  //       iaHdjj: form.value.iaHdjj,

  //       iaZddw: form.value.iaZddw.join(','),
  //       zddwYwrys: JSON.parse(JSON.stringify(zddwYwrys.value)),

  //       iaSsdw: form.value.iaSsdw.join(','),
  //       ssdwYwrys: JSON.parse(JSON.stringify(ssdwYwrys.value)),

  //       iaXtdw: form.value.iaXtdw.join(','),
  //       xtdwYwrys: JSON.parse(JSON.stringify(xtdwYwrys.value)),

  //       iaAsses: form.value.iaAsses,
  //       //iaZdmb: form.value.iaZdmb,


  //       iaZddwYwry: form.value.iaZddwYwry,

  //       iaSsdwYwry: form.value.iaSsdwYwry,

  //       iaXtdwYwry: form.value.iaXtdwYwry,
  //       iaCbsh: form.value.iaCbsh,
  //       iaBmsh: form.value.iaBmsh,
  //       iaLdsh: form.value.iaLdsh,
  //       cbshId: form.value.cbshId,
  //       bmshId: form.value.bmshId,
  //       ldshId: form.value.ldshId,
  //       iaCjr: form.value.iaCjr,
  //       iaCjrDw: form.value.iaCjrDw,
  //       iaLxfs: form.value.iaLxfs,
  //       iaEmail: form.value.iaEmail,
  //       createTime2: form.value.createTime2,
  //     }).then((res) => {
  //       open.value = false;
  //       proxy.$modal.msgSuccess("修改成功");
  //       getListData();
  //     });
  //   }
  // });
}

// 转换时间
function getTime(time) {
  const d = new Date(time);
  const newTime =
    d.getFullYear() +
    "-" +
    (d.getMonth() + 1) +
    "-" +
    d.getDate() +
    " " +
    d.getHours() +
    ":" +
    d.getMinutes() +
    ":" +
    d.getSeconds();
  return newTime;
}

// 打开人员弹窗
function openSelectUser(num, dw) {
  time.value = new Date().getTime();
  isshow.value = num;
  isDw.value = dw;
  if (dw == "Zddw") {
    if(!form.value.iaZddw || form.value.iaZddw=='' ){
      return proxy.$modal.msgWarning('请先选择指导单位')
    }
    show.value = true;
    nextTick(() => {
      orgIdZddw.value = Array.isArray(form.value.iaZddw)?form.value.iaZddw.join(','):form.value.iaZddw;
      proxy.$refs["selectRef"]?.reset();
      proxy.$refs["selectRef"]?.getTreeselects(orgIdZddw.value);
    });
  } else if (dw == "Ssdw") {
    if(!form.value.iaSsdw || form.value.iaSsdw=='' ){
      return proxy.$modal.msgWarning('请先选择实施单位')
    }
    show.value = true;
    nextTick(() => {
      orgIdSsdw.value = Array.isArray(form.value.iaSsdw)?form.value.iaSsdw.join(','):form.value.iaSsdw;
      proxy.$refs["selectRef"]?.reset();
      proxy.$refs["selectRef"].getTreeselects(orgIdSsdw.value);
    });
  } else if (dw == "Xtdw") {
    if(!form.value.iaXtdw || form.value.iaXtdw==''){
      return proxy.$modal.msgWarning('请先选择协同单位')
    }
    show.value = true;
    nextTick(() => {
      orgIdXtdw.value = Array.isArray(form.value.iaXtdw)?form.value.iaXtdw.join(','):form.value.iaXtdw;
      proxy.$refs["selectRef"]?.reset();
      proxy.$refs["selectRef"].getTreeselects(orgIdXtdw.value);
    });
  } else {
    show.value = true;
    nextTick(() => {
      proxy.$refs["selectRef"]?.reset();
      proxy.$refs["selectRef"].getAllTreeselect();
    });
  }

}

// 提交人员
function ok() {
  show.value = false;
  nextTick(() => {
    proxy.$refs["selectRef"].submit();
  });
}

/** 关闭人员弹窗 */
function cancelP() {
  show.value = false;
  proxy.$refs["selectRef"].reset();
}

// 获取人名
function getGroupName(data) {
  let arr = [];
  data.forEach((item) => {
    arr.push(item.realName);
  });
  return arr.join(",");
}

// 选择的数据
function getSelectList(val) {
  let value = JSON.parse(JSON.stringify(val));
  switch (isDw.value) {
    case "Zddw":
      form.value.iaZddwYwry = getGroupName(value);
      zddwYwryList.value = value;
      break;
    case "Ssdw":
      form.value.iaSsdwYwry = getGroupName(value);
      ssdwYwryList.value = value;
      break;
    case "Xtdw":
      form.value.iaXtdwYwry = getGroupName(value);
      xtdwYwryList.value = value;
      break;
    case "Cbsh":
      form.value.iaCbsh = value[0].realName;
      form.value.cbshId = value[0].uuid;
      break;
    case "Bmsh":
      form.value.iaBmsh = value[0].realName;
      form.value.bmshId = value[0].uuid;
      break;
    case "Ldsh":
      form.value.iaLdsh = value[0].realName;
      form.value.ldshId = value[0].uuid;
      break;
    default:
      break;
  }
}

//关闭dialog
function closeDialog() {
  open.value = false;
  reset();
}

//serchig
function serchig() {
  if (serch.value.iaName !== "") {
    isShowTab.value = true;
    serchList({
      iaName: serch.value.iaName,
    }).then((res) => {
      serchData.value = res.data;
    });
  } else {
    isShowTab.value = false;
  }
}

function remoteMethod(query) {
  if (query !== '') {
    serchloading.value = true;
    setTimeout(() => {
      serchloading.value = false;
      serchList({
        iaName: query,
      }).then((res) => {
        serchData.value = res.data;
      });
    }, 200);
  } else {
    serchData.value = [];
  }
}


function searClik(item) {
  isShowTab.value = false;
  serch.value = {};
  let id = item.iaId;
  //getImport(id).then((res) => {
  openCheck.value = true;
  //});
  checkForm.value.iaName = item.iaName;
  checkForm.value.iaNumber = item.iaNumber;
  checkForm.value.iaProvince = item.iaProvince;
  checkForm.value.iaCity = item.iaCity;
  checkForm.value.iaCounties = item.iaCounties;
  checkForm.value.iaCode = item.iaCode;
  checkForm.value.iaStartingTime = item.iaStartingTime;
  checkForm.value.iaFinshTime = item.iaFinshTime;
  checkForm.value.iaAsses = item.iaAsses;
  checkForm.value.iaZdmb = item.iaZdmb;
  checkForm.value.iaWjtz = item.iaWjtz;
  checkForm.value.iaHdjj = item.iaHdjj;

  checkForm.value.jczDw = item.jczDw;
  checkForm.value.jczZz = item.jczZz;
  checkForm.value.jczCy = item.jczCy;
  checkForm.value.jczZyzz = item.jczZyzz;
  checkForm.value.jczGzcs = item.jczGzcs;

  checkForm.value.fxzDw = item.fxzDw;
  checkForm.value.fxzZz = item.fxzZz;
  checkForm.value.fxzCy = item.fxzCy;
  checkForm.value.fxzZyzz = item.fxzZyzz;
  checkForm.value.fxzGzcs = item.fxzGzcs;

  checkForm.value.yjzDw = item.yjzDw;
  checkForm.value.yjzZz = item.yjzZz;
  checkForm.value.yjzCy = item.yjzCy;
  checkForm.value.yjzZyzz = item.yjzZyzz;
  checkForm.value.yjzGzcs = item.yjzGzcs;

  checkForm.value.yjzDw = item.yjzDw;
  checkForm.value.yjzZz = item.yjzZz;
  checkForm.value.yjzCy = item.yjzCy;
  checkForm.value.yjzZyzz = item.yjzZyzz;
  checkForm.value.yjzGzcs = item.yjzGzcs;

  checkForm.value.yjzDw = item.yjzDw;
  checkForm.value.yjzZz = item.yjzZz;
  checkForm.value.yjzCy = item.yjzCy;
  checkForm.value.yjzZyzz = item.yjzZyzz;
  checkForm.value.yjzGzcs = item.yjzGzcs;

  checkForm.value.xwzDw = item.xwzDw;
  checkForm.value.xwzZz = item.xwzZz;
  checkForm.value.xwzCy = item.xwzCy;
  checkForm.value.xwzZyzz = item.xwzZyzz;
  checkForm.value.xwzGzcs = item.xwzGzcs;

  checkForm.value.zszDw = item.zszDw;
  checkForm.value.zszZz = item.zszZz;
  checkForm.value.zszCy = item.zszCy;
  checkForm.value.zszZyzz = item.zszZyzz;
  checkForm.value.zszGzcs = item.zszGzcs;

  checkForm.value.iaZddw = item.iaZddw;
  checkForm.value.iaZddwYwry = item.iaZddwYwry;
  checkForm.value.iaSsdw = item.iaSsdw;
  checkForm.value.iaSsdwYwry = item.iaSsdwYwry;
  checkForm.value.iaXtdw = item.iaXtdw;
  checkForm.value.iaXtdwYwry = item.iaXtdwYwry;
  checkForm.value.iaCbsh = item.iaCbsh;
  checkForm.value.iaBmsh = item.iaBmsh;
  checkForm.value.iaLdsh = item.iaLdsh;
  checkForm.value.iaCjr = item.iaCjr;
  checkForm.value.iaCjrDw = item.iaCjrDw;
  checkForm.value.iaLxfs = item.iaLxfs;
  checkForm.value.iaEmail = item.iaEmail;
}

//
function addZdmb() {
  iSZdmb.value = true;
}

//toLeadForm导入
function toLeadForm() {
  form.value = {};
  zddwYwryList.value = []
  ssdwYwryList.value = []
  xtdwYwryList.value = []
  form.value = checkForm.value
  // form.value.iaZddw = checkForm.value.iaZddw;
  // chooseIaZddw(form.value.iaZddw);
  // chooseIaSsdw(form.value.iaSsdw);
  // chooseIaXtdw(form.value.iaXtdw);
  form.value.iaCjr = userStore.name;
  form.value.createTime2 = getNowFormatDate();
  form.value.iaCjrDw = localStorage.getItem("orgName");
  form.value.time = [form.value.iaStartingTime, form.value.iaFinshTime];

  getActivityIdList().then((res) => {
    form.value.iaNumber = res.data.nextSerialNo;

  });
  if (form.value.zddwYwrys != null && form.value.zddwYwrys != '') {
    form.value.zddwYwrys.forEach((item) => {
      zddwYwryList.value.push({
        "uuid": item.id,
        "realName": item.name,
        "iaZddwYwryFg": item.duties
      });
    });
  }
  if (form.value.ssdwYwrys != null && form.value.ssdwYwrys != '') {
    form.value.ssdwYwrys.forEach((item) => {
      ssdwYwryList.value.push({
        "uuid": item.id,
        "realName": item.name,
        "iaSsdwYwryFg": item.duties
      });
    });
  }
  if (form.value.xtdwYwrys != null && form.value.xtdwYwrys != '') {
    form.value.xtdwYwrys.forEach((item) => {
      xtdwYwryList.value.push({
        "uuid": item.id,
        "realName": item.name,
        "iaXtdwYwryFg": item.duties
      });
    });
  }
  editProvinceFormData(checkForm.value.provinceId, checkForm.value.cityId)

  const query = { province: checkForm.value.provinceId, city: checkForm.value.cityId, county: checkForm.value.countiesId }
  getZdmb(query).then(res => {
    optionZd.value = res.data;
    form.value.iaZdmb = checkForm.value.iaZdmb;
    form.value.iaZdmbs = checkForm.value.iaZdmb.split(',');
  })

  openCheck.value = false;
}

//表单重置
function reset() {
  form.value = {};
  serch.value = {};
  iaZdmbList.value = [];
  proxy.resetForm("singleRef");
}

//进入
function handleEnter(row) {
  // router.push('/incident')
  router.push({
    path: "/activities/incident",
    query: {
      id: row.iaId,
      metaTitle: row.iaName + '管理'
    }
  })
}
// 获取人名
function getZdmbName(data) {
  let arr = [];
  data.forEach((item) => {
    arr.push(item.iaZdmbItem);
  });
  return arr.join(",");
}

//重点目标操作
function handleBlur() {
  getName({ ssJzwmc: form.value.iaZdmb }).then((res) => {

  });
}

// 添加小组成员
function addMembers() {
  queryList.value.MemberList = indexData(form.value.MemberList);
}
//选择历史安保事件
function chooseIaName(value) {
  const iaId = JSON.parse(JSON.stringify(value))
  getImport(iaId).then(response => {
    nextTick(()=>{
      checkForm.value = response.data.importantActivity;
      checkForm.value.iaZddw = response.data.importantActivity.iaZddw.split(',');
      checkForm.value.iaSsdw = response.data.importantActivity.iaSsdw.split(',');
      checkForm.value.iaXtdw = response.data.importantActivity.iaXtdw.split(',');
      checkForm.value.fileList = response.data.list;
      openCheck.value = true;
    })
  });
}
function clickIaName(iaId) {
  getImport(iaId).then(response => {
    checkForm.value = {};
    checkForm.value = response.data.importantActivity;
    checkForm.value.iaZddw = response.data.importantActivity.iaZddw.split(',');
    checkForm.value.iaSsdw = response.data.importantActivity.iaSsdw.split(',');
    checkForm.value.iaXtdw = response.data.importantActivity.iaXtdw.split(',');
    checkForm.value.fileList = response.data.list;
    openCheck.value = true;

  });
}

//选择任务名称
function chooseRwmc(value) {
  rwmc.value = value.join(',')
}

//选择指导单位
function chooseIaZddw(value) {
  orgIdZddw.value = value.join(',')
}
//选择实施单位
function chooseIaSsdw(value) {
  // var orgIdSsdwArr = JSON.parse(JSON.stringify(value))
  // if (orgIdSsdwArr.length == 1) {
  //   orgIdSsdw.value = orgIdSsdwArr[0]
  //   form.value.iaSsdw = orgIdSsdwArr[0]
  // } else if (orgIdSsdwArr.length == 2) {
  //   orgIdSsdw.value = orgIdSsdwArr[1]
  //   form.value.iaSsdw = orgIdSsdwArr[1]
  // } else if (orgIdSsdwArr.length == 3) {
  //   orgIdSsdw.value = orgIdSsdwArr[2]
  //   form.value.iaSsdw = orgIdSsdwArr[2]
  // }
  orgIdSsdw.value = value.join(',')
}
//选择协同单位
function chooseIaXtdw(value) {
  // var orgIdXtdwArr = JSON.parse(JSON.stringify(value))
  // if (orgIdXtdwArr.length == 1) {
  //   orgIdXtdw.value = orgIdXtdwArr[0]
  //   form.value.iaXtdw = orgIdXtdwArr[0]
  // } else if (orgIdXtdwArr.length == 2) {
  //   orgIdXtdw.value = orgIdXtdwArr[1]
  //   form.value.iaXtdw = orgIdXtdwArr[1]
  // } else if (orgIdXtdwArr.length == 3) {
  //   orgIdXtdw.value = orgIdXtdwArr[2]
  //   form.value.iaXtdw = orgIdXtdwArr[2]
  // }
  orgIdXtdw.value = value.join(',')
}

//删除指导单位
function delZddwYwry(index, item) {
  zddwYwryList.value.splice(index, 1);
  form.value.iaZddwYwry = getGroupName(zddwYwryList.value);
}
//删除实施单位
function delSsdwYwry(index, item) {
  ssdwYwryList.value.splice(index, 1);
  form.value.iaSsdwYwry = getGroupName(ssdwYwryList.value);
}
//删除协同单位
function delXtdwYwry(index, item) {
  xtdwYwryList.value.splice(index, 1);
  form.value.iaXtdwYwry = getGroupName(xtdwYwryList.value);
}
//点击任务分工
function taskFg() {
  openFg.value = true;
}
function taskFg1() {
  openFg1.value = true;
}
// 重要目标
function getZd() {
  if (form.value.provinceId) {
    const query = { province: form.value.provinceId, city: form.value.cityId, county: form.value.countiesId }
    getZdmb(query).then(res => {
      optionZd.value = res.data;
    })
  } else {
    proxy.$modal.msgWarning('请先选择省市区县')
  }
}
const uploadFile = (file) => {
  form.value.fileList = proxy.$refs["fileUpload"].fileList
  form.value.fileIds = form.value.fileList.map(item => item.attachId).join(',')
  proxy.$refs.singleRef.clearValidate('fileIds')
}
const delFile = (index) => {
  form.value.fileList.splice(index, 1);
}
const goKeyplace = () => {
  router.push('/security/keyplace')
}

// 获取登陆人信息
function getInfo(){
  getAdmin().then(res=>{
    if(res.data=='0'){
      /** 获取省列表 */
      getProvince().then((response) => {
        provinceData.value = response.data;
        provinceFormData.value = response.data;
      });
    }else{
      getProvince().then((response) => {
        provinceData.value = response.data.filter(item=>item.id==res.data);
        provinceFormData.value = response.data.filter(item=>item.id==res.data);
      });
    }
  })
}
getInfo();

onMounted(() => {
  getListData();
  // getProvinceData();
  getDwData();
})
</script>

<style>
.tabitem {
  list-style: none;
  height: 32px;
  line-height: 32px;
  text-align: left;
  margin-left: -40px;
  border: 1px solid;
}

.tabitem:hover {
  background-color: #107ce5;
  color: #ffff;
}

.navtab {
  width: 550px;
  /* margin-top: -23px; */
  position: absolute;
  height: 100%;
  margin-top: -45px;
  z-index: 1005;
  background-color: #fff;
}

.navwrap {
  font-size: 0.26rem;
  width: 100%;
  /* color: #c2c2c2; */
  background-color: #fff;
}

.input {
  width: 550px;
}

.tab-title {
  font-size: 16px;
  font-weight: bold;
  border-left: 4px solid #0D9AFF;
  font-family: PingFangSC-Medium;
  padding-left: 10px;
  margin-bottom: 20px;
}
.enterReview{
  /* 阻止鼠标事件 */
  pointer-events: none; 
}
</style>
  